/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package bpmn.impl;

import bpmn.BpmnPackage;
import bpmn.Expression;
import bpmn.StandardLoopActivity;
import bpmn.TestTimeType;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Standard Loop Activity</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link bpmn.impl.StandardLoopActivityImpl#getLoopCondition <em>Loop Condition</em>}</li>
 *   <li>{@link bpmn.impl.StandardLoopActivityImpl#getLoopCounter <em>Loop Counter</em>}</li>
 *   <li>{@link bpmn.impl.StandardLoopActivityImpl#getLoopMaximum <em>Loop Maximum</em>}</li>
 *   <li>{@link bpmn.impl.StandardLoopActivityImpl#getTestTime <em>Test Time</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class StandardLoopActivityImpl extends ActivityImpl implements StandardLoopActivity {
	/**
	 * The cached value of the '{@link #getLoopCondition() <em>Loop Condition</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopCondition()
	 * @generated
	 * @ordered
	 */
	protected Expression loopCondition;

	/**
	 * The default value of the '{@link #getLoopCounter() <em>Loop Counter</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopCounter()
	 * @generated
	 * @ordered
	 */
	protected static final Integer LOOP_COUNTER_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLoopCounter() <em>Loop Counter</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopCounter()
	 * @generated
	 * @ordered
	 */
	protected Integer loopCounter = LOOP_COUNTER_EDEFAULT;

	/**
	 * The default value of the '{@link #getLoopMaximum() <em>Loop Maximum</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopMaximum()
	 * @generated
	 * @ordered
	 */
	protected static final Integer LOOP_MAXIMUM_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLoopMaximum() <em>Loop Maximum</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLoopMaximum()
	 * @generated
	 * @ordered
	 */
	protected Integer loopMaximum = LOOP_MAXIMUM_EDEFAULT;

	/**
	 * The default value of the '{@link #getTestTime() <em>Test Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTestTime()
	 * @generated
	 * @ordered
	 */
	protected static final TestTimeType TEST_TIME_EDEFAULT = TestTimeType.BEFORE;

	/**
	 * The cached value of the '{@link #getTestTime() <em>Test Time</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTestTime()
	 * @generated
	 * @ordered
	 */
	protected TestTimeType testTime = TEST_TIME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StandardLoopActivityImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BpmnPackage.Literals.STANDARD_LOOP_ACTIVITY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression getLoopCondition() {
		if (loopCondition != null && loopCondition.eIsProxy()) {
			InternalEObject oldLoopCondition = (InternalEObject)loopCondition;
			loopCondition = (Expression)eResolveProxy(oldLoopCondition);
			if (loopCondition != oldLoopCondition) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_CONDITION, oldLoopCondition, loopCondition));
			}
		}
		return loopCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Expression basicGetLoopCondition() {
		return loopCondition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLoopCondition(Expression newLoopCondition) {
		Expression oldLoopCondition = loopCondition;
		loopCondition = newLoopCondition;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_CONDITION, oldLoopCondition, loopCondition));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Integer getLoopCounter() {
		return loopCounter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLoopCounter(Integer newLoopCounter) {
		Integer oldLoopCounter = loopCounter;
		loopCounter = newLoopCounter;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_COUNTER, oldLoopCounter, loopCounter));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Integer getLoopMaximum() {
		return loopMaximum;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLoopMaximum(Integer newLoopMaximum) {
		Integer oldLoopMaximum = loopMaximum;
		loopMaximum = newLoopMaximum;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_MAXIMUM, oldLoopMaximum, loopMaximum));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TestTimeType getTestTime() {
		return testTime;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTestTime(TestTimeType newTestTime) {
		TestTimeType oldTestTime = testTime;
		testTime = newTestTime == null ? TEST_TIME_EDEFAULT : newTestTime;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, BpmnPackage.STANDARD_LOOP_ACTIVITY__TEST_TIME, oldTestTime, testTime));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_CONDITION:
				if (resolve) return getLoopCondition();
				return basicGetLoopCondition();
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_COUNTER:
				return getLoopCounter();
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_MAXIMUM:
				return getLoopMaximum();
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__TEST_TIME:
				return getTestTime();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_CONDITION:
				setLoopCondition((Expression)newValue);
				return;
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_COUNTER:
				setLoopCounter((Integer)newValue);
				return;
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_MAXIMUM:
				setLoopMaximum((Integer)newValue);
				return;
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__TEST_TIME:
				setTestTime((TestTimeType)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_CONDITION:
				setLoopCondition((Expression)null);
				return;
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_COUNTER:
				setLoopCounter(LOOP_COUNTER_EDEFAULT);
				return;
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_MAXIMUM:
				setLoopMaximum(LOOP_MAXIMUM_EDEFAULT);
				return;
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__TEST_TIME:
				setTestTime(TEST_TIME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_CONDITION:
				return loopCondition != null;
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_COUNTER:
				return LOOP_COUNTER_EDEFAULT == null ? loopCounter != null : !LOOP_COUNTER_EDEFAULT.equals(loopCounter);
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__LOOP_MAXIMUM:
				return LOOP_MAXIMUM_EDEFAULT == null ? loopMaximum != null : !LOOP_MAXIMUM_EDEFAULT.equals(loopMaximum);
			case BpmnPackage.STANDARD_LOOP_ACTIVITY__TEST_TIME:
				return testTime != TEST_TIME_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (LoopCounter: ");
		result.append(loopCounter);
		result.append(", LoopMaximum: ");
		result.append(loopMaximum);
		result.append(", TestTime: ");
		result.append(testTime);
		result.append(')');
		return result.toString();
	}

} //StandardLoopActivityImpl
